/*     */ package com.qmsk.business.member.memberIntegralRule.service;
/*     */ 
/*     */ import com.qmsk.business.bussBill.bussBill.dao.BussBillDao;
/*     */ import com.qmsk.business.member.memberIntegralBill.dao.MemberIntegralBillDao;
/*     */ import com.qmsk.business.member.memberIntegralDetail.dao.MemberIntegralDetailDAO;
/*     */ import com.qmsk.business.member.memberIntegralRule.dao.MemberIntegralRuleDAO;
/*     */ import com.qmsk.business.member.shopMember.dao.ShopMemberDAO;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.gson.out.GsonEbRstData;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Service;
/*     */ 
/*     */ @Service
/*     */ public class MemberIntegralRuleService
/*     */ {
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralDetailDAO memberinDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralRuleDAO memberIntegralRuleDAO;
/*     */ 
/*     */   @Autowired
/*     */   private BussBillDao bussBillDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralBillDao memberIntegralBillDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberIntegralDetailDAO memberIntegralDetailDAO;
/*     */ 
/*     */   @Autowired
/*     */   private ShopMemberDAO shopMemberDAO;
/*     */ 
/*     */   public Map<String, Object> sendIntegralOfRuleNameAndMemberId(String ruleName, Long memberId, Long shopId)
/*     */     throws SQLException
/*     */   {
/*  38 */     Map reuslt = new HashMap();
/*  39 */     int nResult = 1;
/*  40 */     GsonHeadOneRow g = this.shopMemberDAO.getPaidOneRowOfMemberId(memberId, 
/*  41 */       shopId);
/*  42 */     if (g == null) {
/*  43 */       reuslt.put("nResult", Integer.valueOf(1));
/*  44 */       return reuslt;
/*     */     }
/*  46 */     String openId = (String)g.getValueOfName("openId");
/*  47 */     String customerName = (String)g.getValueOfName("customerName");
/*  48 */     String mp = (String)g.getValueOfName("mp");
/*  49 */     GsonEbRst intg = this.memberIntegralRuleDAO.getGsonOfNameAndMemberIdAndCus(
/*  50 */       ruleName, memberId, Integer.valueOf(1));
/*  51 */     Integer intAmt = Integer.valueOf(0);
/*  52 */     if ((intg != null) && (intg.getDataLength() > 0)) {
/*  53 */       Long RuleID = (Long)intg.getResult().getValueOfIdx(0, "RuleID");
/*  54 */       intAmt = (Integer)intg.getResult().getValueOfIdx(0, 
/*  55 */         "FixedIntegral");
/*  56 */       Map params = new HashMap();
/*  57 */       params.put("memberId", memberId);
/*  58 */       params.put("shopId", shopId);
/*  59 */       params.put("intAmt", intAmt);
/*  60 */       nResult = this.shopMemberDAO.updateBissBillAmountInc(params);
/*  61 */       String billNO = this.bussBillDao.getMaxBillNo(shopId);
/*  62 */       String[] head = { "ShopID", "BillNo", "MemberID", 
/*  63 */         "CustName", "GotIntAmt" };
/*  64 */       Object[] data = { shopId, billNO, memberId, 
/*  65 */         customerName, intAmt };
/*  66 */       nResult = this.bussBillDao.insertGsonHeadOneRow(
/*  67 */         new GsonHeadOneRow(head, 
/*  67 */         data));
/*  68 */       if (nResult > 0) {
/*  69 */         Long billId = this.bussBillDao.getLastId();
/*  70 */         nResult = this.memberIntegralBillDao.insertBsBillInAmtOfService(
/*  71 */           billNO, memberId, shopId, intAmt, RuleID, ruleName, 
/*  72 */           null, null, billId, null);
/*  73 */         if (nResult > 0) {
/*  74 */           String[] detilHead = { "ShopID", "Integral", 
/*  75 */             "MemberID", "BillID", "Status" };
/*  76 */           Object[] detilData = { shopId, intAmt, 
/*  77 */             memberId, billId, Integer.valueOf(0) };
/*  78 */           nResult = this.memberinDetailDAO
/*  79 */             .insertGsonHeadOneRow(new GsonHeadOneRow(detilHead, 
/*  80 */             detilData));
/*     */         }
/*     */       }
/*     */     }
/*  84 */     reuslt.put("intAmt", intAmt);
/*  85 */     reuslt.put("customerName", customerName);
/*  86 */     reuslt.put("nResult", Integer.valueOf(nResult));
/*  87 */     reuslt.put("mp", mp);
/*  88 */     reuslt.put("openId", openId);
/*  89 */     return reuslt;
/*     */   }
/*     */ 
/*     */   public Map<String, Object> sendIntegralOfRuleName(String ruleName, Long memberId, Long shopId) throws SQLException
/*     */   {
/*  94 */     Map reuslt = new HashMap();
/*  95 */     int nResult = 1;
/*  96 */     GsonHeadOneRow g = this.shopMemberDAO.getPaidOneRowOfMemberId(memberId, 
/*  97 */       shopId);
/*  98 */     if (g == null) {
/*  99 */       reuslt.put("nResult", Integer.valueOf(1));
/* 100 */       return reuslt;
/*     */     }
/* 102 */     String openId = (String)g.getValueOfName("openId");
/* 103 */     String customerName = (String)g.getValueOfName("customerName");
/* 104 */     String mp = (String)g.getValueOfName("mp");
/* 105 */     GsonEbRst intg = this.memberIntegralRuleDAO
/* 106 */       .getGsonOfNameAndMemberIdAndCus(ruleName);
/* 107 */     Integer intAmt = Integer.valueOf(0);
/* 108 */     if ((intg != null) && (intg.getDataLength() > 0)) {
/* 109 */       Long RuleID = (Long)intg.getResult().getValueOfIdx(0, "RuleID");
/* 110 */       intAmt = (Integer)intg.getResult().getValueOfIdx(0, 
/* 111 */         "FixedIntegral");
/* 112 */       Map params = new HashMap();
/* 113 */       params.put("memberId", memberId);
/* 114 */       params.put("shopId", shopId);
/* 115 */       params.put("intAmt", intAmt);
/* 116 */       nResult = this.shopMemberDAO.updateBissBillAmountInc(params);
/* 117 */       String billNO = this.bussBillDao.getMaxBillNo(shopId);
/* 118 */       String[] head = { "ShopID", "BillNo", "MemberID", 
/* 119 */         "CustName", "GotIntAmt" };
/* 120 */       Object[] data = { shopId, billNO, memberId, 
/* 121 */         customerName, intAmt };
/* 122 */       nResult = this.bussBillDao.insertGsonHeadOneRow(
/* 123 */         new GsonHeadOneRow(head, 
/* 123 */         data));
/* 124 */       if (nResult > 0) {
/* 125 */         Long billId = this.bussBillDao.getLastId();
/* 126 */         nResult = this.memberIntegralBillDao.insertBsBillInAmtOfService(
/* 127 */           billNO, memberId, shopId, intAmt, RuleID, ruleName, 
/* 128 */           null, null, billId, null);
/* 129 */         if (nResult > 0) {
/* 130 */           String[] detilHead = { "ShopID", "Integral", 
/* 131 */             "MemberID", "BillID", "Status" };
/* 132 */           Object[] detilData = { shopId, intAmt, 
/* 133 */             memberId, billId, Integer.valueOf(0) };
/* 134 */           nResult = this.memberinDetailDAO
/* 135 */             .insertGsonHeadOneRow(new GsonHeadOneRow(detilHead, 
/* 136 */             detilData));
/*     */         }
/*     */       }
/*     */     }
/* 140 */     reuslt.put("intAmt", intAmt);
/* 141 */     reuslt.put("customerName", customerName);
/* 142 */     reuslt.put("nResult", Integer.valueOf(nResult));
/* 143 */     reuslt.put("mp", mp);
/* 144 */     reuslt.put("openId", openId);
/* 145 */     return reuslt;
/*     */   }
/*     */ 
/*     */   public Map<String, Object> sendIntegralByRuleNameAndOpenIdOfOneDay(String ruleName, String openId, Long shopId)
/*     */     throws SQLException
/*     */   {
/* 156 */     Map reuslt = new HashMap();
/*     */ 
/* 158 */     GsonHeadOneRow member = this.shopMemberDAO
/* 159 */       .getGsonOnRowOfShopIdAndOpenId(openId, shopId);
/* 160 */     if ((member == null) || (member.getDataLength() == 0)) {
/* 161 */       reuslt.put("nResult", Integer.valueOf(-1));
/* 162 */       reuslt.put("msg", "暂无此会员");
/* 163 */       return reuslt;
/*     */     }
/*     */ 
/* 166 */     Long memberId = ObjectComm.objectToLong(member
/* 167 */       .getValueOfName("memberId"));
/* 168 */     String custName = (String)member
/* 169 */       .getValueOfName("CustomerName");
/* 170 */     String mp = (String)member
/* 171 */       .getValueOfName("mp");
/* 172 */     if (this.memberIntegralBillDao.checkExistByNameOneDay(
/* 173 */       ruleName, memberId).intValue() > 0)
/*     */     {
/* 174 */       reuslt.put("nResult", Integer.valueOf(-2));
/* 175 */       reuslt.put("msg", "今日已送过积分");
/* 176 */       return reuslt;
/*     */     }
/*     */ 
/* 179 */     GsonHeadOneRow memberIntgRule = this.memberIntegralRuleDAO
/* 180 */       .getGsonOneRowOfName(ruleName);
/* 181 */     if ((memberIntgRule == null) || (memberIntgRule.getDataLength() == 0)) {
/* 182 */       reuslt.put("nResult", Integer.valueOf(-3));
/* 183 */       reuslt.put("msg", "规则不可用");
/* 184 */       return reuslt;
/*     */     }
/* 186 */     int nResult = 0;
/* 187 */     Integer intAmt = (Integer)memberIntgRule.getValueOfName("FixedIntegral");
/* 188 */     Long RuleID = (Long)memberIntgRule.getValueOfName("RuleID");
/* 189 */     Map params = new HashMap();
/* 190 */     params.put("memberId", memberId);
/* 191 */     params.put("shopId", shopId);
/* 192 */     params.put("intAmt", intAmt);
/* 193 */     nResult = this.shopMemberDAO.updateBissBillAmountInc(params);
/* 194 */     String billNO = this.bussBillDao.getMaxBillNo(shopId);
/* 195 */     String[] head = { "ShopID", "BillNo", "MemberID", 
/* 196 */       "CustName", "GotIntAmt" };
/* 197 */     Object[] data = { shopId, billNO, memberId, custName, 
/* 198 */       intAmt };
/* 199 */     nResult = this.bussBillDao.insertGsonHeadOneRow(
/* 200 */       new GsonHeadOneRow(head, 
/* 200 */       data));
/* 201 */     if (nResult > 0) {
/* 202 */       Long billId = this.bussBillDao.getLastId();
/* 203 */       nResult = this.memberIntegralBillDao.insertBsBillInAmtOfService(
/* 204 */         billNO, memberId, shopId, intAmt, RuleID, ruleName, 
/* 205 */         null, null, billId, null);
/* 206 */       if (nResult > 0) {
/* 207 */         String[] detilHead = { "ShopID", "Integral", 
/* 208 */           "MemberID", "BillID", "Status" };
/* 209 */         Object[] detilData = { shopId, intAmt, 
/* 210 */           memberId, billId, Integer.valueOf(0) };
/* 211 */         nResult = this.memberIntegralDetailDAO
/* 212 */           .insertGsonHeadOneRow(new GsonHeadOneRow(detilHead, 
/* 213 */           detilData));
/*     */       }
/*     */     }
/* 216 */     reuslt.put("intAmt", intAmt);
/* 217 */     reuslt.put("customerName", custName);
/* 218 */     reuslt.put("nResult", Integer.valueOf(nResult));
/* 219 */     reuslt.put("mp", mp);
/* 220 */     reuslt.put("msg", "success");
/* 221 */     return reuslt;
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberIntegralRule.service.MemberIntegralRuleService
 * JD-Core Version:    0.5.3
 */